package com.newwing.fenxiao.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.SortedMap;
import java.util.TreeMap;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.DateUtils;
import org.json.JSONException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.newwing.fenxiao.entities.Commission;
import com.newwing.fenxiao.entities.Config;
import com.newwing.fenxiao.entities.Financial;
import com.newwing.fenxiao.entities.Kami;
import com.newwing.fenxiao.entities.Orders;
import com.newwing.fenxiao.entities.Product;
import com.newwing.fenxiao.entities.User;
import com.newwing.fenxiao.pay.RSASignature;
import com.newwing.fenxiao.service.ICommissionService;
import com.newwing.fenxiao.service.IConfigService;
import com.newwing.fenxiao.service.IFinancialService;
import com.newwing.fenxiao.service.IKamiService;
import com.newwing.fenxiao.service.IOrdersService;
import com.newwing.fenxiao.service.IProductService;
import com.newwing.fenxiao.service.IUserService;
import com.newwing.fenxiao.utils.BjuiJson;
import com.newwing.fenxiao.utils.BjuiPage;
import com.newwing.fenxiao.utils.FreemarkerUtils;
import com.newwing.fenxiao.utils.PageModel;
import com.util.HttpClientNewUtil;
import com.util.Signature;
import com.weixin.utils.GetWxOrderno;
import com.weixin.utils.RequestHandler;
import com.weixin.utils.Sha1Util;
import com.weixin.utils.TenpayUtil;

import freemarker.template.Configuration;

@Controller("ordersAction")
@Scope("prototype")
public class OrdersAction extends BaseAction {
	
	private static final long serialVersionUID = 1L;
	private String bankType;
	private String bankAccountType;
	
	@Resource(name = "ordersService")
	private IOrdersService<Orders> ordersService;

	@Resource(name = "userService")
	private IUserService<User> userService;

	@Resource(name = "productService")
	private IProductService<Product> productService;

	@Resource(name = "kamiService")
	private IKamiService<Kami> kamiService;

	@Resource(name = "financialService")
	private IFinancialService<Financial> financialService;

	@Resource(name = "commissionService")
	private ICommissionService<Commission> commissionService;
	private Orders orders;
	private String ftlFileName;

	@Resource(name = "configService")
	private IConfigService<Config> configService;

	public void list() {
		String key = this.request.getParameter("key");
		String countHql = "select count(*) from Orders where deleted=0 and status!=0";
		String hql = "from Orders where deleted=0 and status!=0";
		if (StringUtils.isNotEmpty(key)) {
			countHql = countHql + " and (user.name='" + key + "' or no='" + key + "' or productName='" + key + "')";
			hql = hql + " and (user.name='" + key + "' or no='" + key + "' or productName='" + key + "')";
		}
		hql = hql + " order by id desc";

		int count = 0;
		count = this.ordersService.getTotalCount(countHql, new Object[0]);
		this.page = new BjuiPage(this.pageCurrent, this.pageSize);
		this.page.setTotalCount(count);
		this.cfg = new Configuration();

		this.cfg.setServletContextForTemplateLoading(this.request.getServletContext(), "WEB-INF/templates/admin");
		List ordersList = this.ordersService.list(hql, this.page.getStart(), this.page.getPageSize(), new Object[0]);
		Map root = new HashMap();
		root.put("ordersList", ordersList);
		root.put("page", this.page);
		root.put("key", key);
		FreemarkerUtils.freemarker(this.request, this.response, this.ftlFileName, this.cfg, root);
	}

	public void add() {
		String pidStr = this.request.getParameter("pid");
		int pid = 0;
		try {
			pid = Integer.parseInt(pidStr);
		} catch (Exception e) {
			this.request.setAttribute("status", "0");
			this.request.setAttribute("message", "参数错误");
			try {
				this.request.getRequestDispatcher("cart.jsp").forward(this.request, this.response);
			} catch (ServletException e1) {
				e1.printStackTrace();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			return;
		}
		Product findProduct = (Product) this.productService.findById(Product.class, pid);
		if (findProduct == null) {
			this.request.setAttribute("status", "0");
			this.request.setAttribute("message", "商品不存在");
		} else {
			this.request.setAttribute("status", "1");
			this.request.setAttribute("product", findProduct);
		}
		try {
			this.request.getRequestDispatcher("cart.jsp").forward(this.request, this.response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void save() {
		String pidStr = this.request.getParameter("pid");
		String numStr = this.request.getParameter("num");
		int pid = 0;
		int num = 1;
		try {
			pid = Integer.parseInt(pidStr);
			num = Integer.parseInt(numStr);
		} catch (Exception e) {
			this.request.setAttribute("status", "0");
			this.request.setAttribute("message", "参数错误");
			try {
				this.request.getRequestDispatcher("orderAdd.jsp").forward(this.request, this.response);
			} catch (ServletException e1) {
				e1.printStackTrace();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			return;
		}
		Product findProduct = (Product) this.productService.findById(Product.class, pid);
		if (findProduct == null) {
			this.request.setAttribute("status", "0");
			this.request.setAttribute("message", "商品不存在");
		} else {
			HttpSession session = this.request.getSession();
			User loginUser = (User) session.getAttribute("loginUser");
			if ((loginUser == null) || (loginUser.getId() == null)) {
				this.request.setAttribute("status", "0");
				this.request.setAttribute("message", "您未登陆或者登陆失效，请重新登陆");
			} else {
				Orders newOrders = new Orders();
				newOrders.setProductId("" + findProduct.getId());
				newOrders.setProductName(findProduct.getTitle());
				newOrders.setProductNum(Integer.valueOf(num));
				newOrders.setProductMoney(findProduct.getMoney());
				newOrders.setUser(loginUser);
				newOrders.setStatus(Integer.valueOf(0));
				newOrders.setMoney(Double.valueOf(num * findProduct.getMoney().doubleValue()));

				Random random = new Random();
				int n = random.nextInt(9999);
				n += 10000;

				String no = "" + System.currentTimeMillis() + n;
				newOrders.setNo(no);

				newOrders.setCreateDate(new Date());
				newOrders.setDeleted(false);
				this.ordersService.saveOrUpdate(newOrders);
				try {
					this.response.sendRedirect("settle?no=" + no);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public void settle() {
		String no = this.request.getParameter("no");
		Orders findOrders = this.ordersService.findByNo(no);
		if (findOrders == null) {
			this.request.setAttribute("status", "0");
			this.request.setAttribute("message", "订单不存在");
		} else {
			HttpSession session = this.request.getSession();
			User loginUser = (User) session.getAttribute("loginUser");
			if ((loginUser == null) || (loginUser.getId() == null)) {
				this.request.setAttribute("status", "0");
				this.request.setAttribute("message", "您未登陆或者登陆失效，请重新登陆");
			} else {
				this.request.setAttribute("orders", findOrders);
				try {
					// TODO 需要在此处传输支付的相关信息
					this.request.getRequestDispatcher("settle.jsp").forward(this.request, this.response);
				} catch (ServletException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public void pay() throws Exception {
		PrintWriter out = null;
		try {
			out = this.response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String no = this.request.getParameter("no");
		bankType = this.request.getParameter("bankType");
		bankAccountType = this.request.getParameter("cardType");
		Orders findOrders = this.ordersService.findByNo(no);
		HttpSession session = this.request.getSession();
		User loginUser = (User) session.getAttribute("loginUser");

		JSONObject json = new JSONObject();
		User findUser = (User) this.userService.findById(User.class, loginUser.getId().intValue());
		if (findOrders == null) {
			json.put("status", "0");
			json.put("message", "订单不存在");
		} else if (findOrders.getUser().getId() != findUser.getId()) {
			json.put("status", "0");
			json.put("message", "没有权限");
		} else if (findOrders.getStatus().intValue() == 1) {
			json.put("status", "0");
			json.put("message", "该订单已付款，请不要重复提交支付");
		} else {
			this.paySubmit(findOrders);
//			String sbHtml = this.paySubmit(findOrders);
//			out.print(sbHtml.toString());
//			out.flush();
//			out.close();
////			return;
		}
		out.print(json.toString());
		out.flush();
		out.close();
	}

	public void detail() {
		String no = this.request.getParameter("no");
		Orders findOrders = this.ordersService.findByNo(no);
		if (findOrders == null) {
			this.request.setAttribute("status", "0");
			this.request.setAttribute("message", "订单不存在");
		} else {
			HttpSession session = this.request.getSession();
			User loginUser = (User) session.getAttribute("loginUser");
			if (findOrders.getUser().getId() != loginUser.getId()) {
				this.request.setAttribute("status", "0");
				this.request.setAttribute("message", "没有权限");
			} else {
				this.request.setAttribute("orders", findOrders);
				try {
					this.request.getRequestDispatcher("ordersDetail.jsp").forward(this.request, this.response);
				} catch (ServletException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public void indexList() {
		String pStr = this.request.getParameter("p");
		int p = 1;
		if (!StringUtils.isEmpty(pStr)) {
			p = Integer.parseInt(pStr);
		}

		String type = this.request.getParameter("type");
		HttpSession session = this.request.getSession();
		User loginUser = (User) session.getAttribute("loginUser");
		String countHql = "select count(*) from Orders where deleted=0 and user.id=" + loginUser.getId();
		String hql = "from Orders where deleted=0 and user.id=" + loginUser.getId();
		if (("0".equals(type)) || ("1".equals(type))) {
			countHql = countHql + " and status=" + type;
			hql = hql + " and status=" + type;
		}
		hql = hql + " order by id desc";

		int count = 0;
		count = this.ordersService.getTotalCount(countHql, new Object[0]);
		PageModel pageModel = new PageModel();
		pageModel.setAllCount(count);
		pageModel.setCurrentPage(p);
		List ordersList = this.ordersService.list(hql, pageModel.getStart(), pageModel.getPageSize(), new Object[0]);
		JSONObject json = new JSONObject();
		if (ordersList.size() == 0) {
			json.put("status", "0");

			json.put("isNextPage", "0");
		} else {
			json.put("status", "1");
			if (ordersList.size() == pageModel.getPageSize()) {
				json.put("isNextPage", "1");
			} else {
				json.put("isNextPage", "0");
			}
			JSONArray listJson = (JSONArray) JSONArray.toJSON(ordersList);
			json.put("list", listJson);
		}
		PrintWriter out = null;
		try {
			out = this.response.getWriter();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		out.print(json);
		out.flush();
		out.close();
	}

	public void info() {
		String idStr = this.request.getParameter("id");
		String callbackData = "";
		PrintWriter out = null;
		try {
			out = this.response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			if ((idStr == null) || ("".equals(idStr))) {
				callbackData = BjuiJson.json("300", "参数不能为空", "", "", "", "", "", "");
			} else {
				int id = 0;
				try {
					id = Integer.parseInt(idStr);
				} catch (Exception e) {
					callbackData = BjuiJson.json("300", "参数错误", "", "", "", "", "", "");
				}
				Orders findorders = (Orders) this.ordersService.findById(Orders.class, id);
				if (findorders == null) {
					callbackData = BjuiJson.json("300", "订单不存在", "", "", "", "", "", "");
				} else {
					this.cfg = new Configuration();

					this.cfg.setServletContextForTemplateLoading(this.request.getServletContext(),
							"WEB-INF/templates/admin");
					Map root = new HashMap();
					root.put("orders", findorders);
					FreemarkerUtils.freemarker(this.request, this.response, this.ftlFileName, this.cfg, root);
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		out.print(callbackData);
		out.flush();
		out.close();
	}
	
	public void indexUpdate() {
		PrintWriter out = null;
		try {
			out = this.response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String callbackData = "";
		String status = this.request.getParameter("status");
		String id = this.request.getParameter("id");
		this.orders = new Orders();
		orders.setId(new Integer(id));
		try {
			if (this.orders == null) {
				callbackData = BjuiJson.json("300", "参数错误", "", "", "", "", "", "");
			} else {
				Orders findorders = (Orders) this.ordersService.findById(Orders.class, this.orders.getId().intValue());
				this.orders.setCreateDate(findorders.getCreateDate());
				this.orders.setDeleted(findorders.isDeleted());
				this.orders.setVersion(findorders.getVersion());
				findorders.setStatus(new Integer(status));// TODO 状态设置为已收货
				boolean result = this.ordersService.saveOrUpdate(findorders);

				if (result) {
					callbackData = BjuiJson.json("200", "修改成功", "", "", "", "true", "", "");
				} else
					callbackData = BjuiJson.json("300", "修改失败", "", "", "", "", "", "");
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
//		out.print(callbackData);
//		out.flush();
//		out.close();
		try {
			response.sendRedirect("ordersList.jsp");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void update() {
		PrintWriter out = null;
		try {
			out = this.response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String callbackData = "";
		String status = this.request.getParameter("status");
		String id = this.request.getParameter("id");
		this.orders = new Orders();
		orders.setId(new Integer(id));
		try {
			if (this.orders == null) {
				callbackData = BjuiJson.json("300", "参数错误", "", "", "", "", "", "");
			} else {
				Orders findorders = (Orders) this.ordersService.findById(Orders.class, this.orders.getId().intValue());
				this.orders.setCreateDate(findorders.getCreateDate());
				this.orders.setDeleted(findorders.isDeleted());
				this.orders.setVersion(findorders.getVersion());
				findorders.setStatus(new Integer(status));// TODO 状态设置为已发货
				boolean result = this.ordersService.saveOrUpdate(findorders);

				if (result) {
					callbackData = BjuiJson.json("200", "修改成功", "", "", "", "true", "", "");
				} else
					callbackData = BjuiJson.json("300", "修改失败", "", "", "", "", "", "");
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		out.print(callbackData);
		out.flush();
		out.close();
	}

	public void delete() {
		PrintWriter out = null;
		try {
			out = this.response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String callbackData = "";
		try {
			String idStr = this.request.getParameter("id");

			if ((idStr == null) || ("".equals(idStr))) {
				callbackData = BjuiJson.json("300", "参数错误", "", "", "", "", "", "");
			} else {
				int id = 0;
				try {
					id = Integer.parseInt(idStr);
				} catch (Exception e) {
					callbackData = BjuiJson.json("300", "参数错误", "", "", "", "", "", "");
				}
				Orders findorders = (Orders) this.ordersService.findById(Orders.class, id);
				if (findorders == null) {
					callbackData = BjuiJson.json("300", "订单不存在", "", "", "", "true", "", "");
				} else {
					boolean result = this.ordersService.delete(findorders);
					if (result)
						callbackData = BjuiJson.json("200", "删除成功", "", "", "", "", "", "");
					else
						callbackData = BjuiJson.json("300", "删除失败", "", "", "", "", "", "");
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		out.print(callbackData);
		out.flush();
		out.close();
	}
	
	
	private void paySubmit(Orders orders) throws Exception {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");

		// 把request请求的参数放到Map中
		Enumeration e = request.getParameterNames();
		SortedMap<String, String> map = new TreeMap<String, String>();
//		while (e.hasMoreElements()) {
//			String param = (String) e.nextElement();
//			map.put(param, request.getParameter(param));
//		}
		String orderAmount = String.valueOf(orders.getMoney() * 100);
		orderAmount = orderAmount.split("\\.")[0];
		
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		
		map.put("versionId", "1.0");
		map.put("orderAmount", orderAmount);
		map.put("orderDate", sdf.format(date));
		map.put("currency", "RMB");
		map.put("transType", "0008");
		map.put("asynNotifyUrl", "http://localhost:8080/Pay_Demo/verifyResultServlet");
		map.put("synNotifyUrl", "http://m.test.foodmall.com");
		map.put("signType", "MD5");
		map.put("merId", "00000000518760");
		map.put("prdOrdNo", orders.getNo());
		map.put("payMode", request.getParameter("payMode"));
		map.put("receivableType", "D00");
		map.put("prdAmt", orderAmount);
		map.put("prdDisUrl", "http://www.icardpay.com");
		
		map.put("prdName", orders.getProductName());
		map.put("prdShortName", orders.getProductName());
		map.put("prdDesc", orders.getProductName());
		map.put("merParam", "");
		
		if("MD5".equalsIgnoreCase(map.get("signType").toString())){
			//#.md5编码并转成大写 签名：
			String sign = Signature.createSign(map,"9YQy38ePf6gQ");
			map.put("signData",sign);
		}
		
		try {
			String resData = HttpClientNewUtil.post("http://pay.chinaxzf.com:8080/payment/ScanPayApply.do", map);//提交到支付系统 
			Map<String, String> retmap = (Map<String, String>) JSON.parse(resData);
			String retCode = (String) retmap.get("retCode");
			String retMsg = (String) retmap.get("retMsg");
			String qrcode = (String) retmap.get("qrcode");
			String platmerord = (String) retmap.get("platmerord");
			String signType = (String) retmap.get("signType");
			String signData = (String) retmap.get("signData");
			
			if("1".equals(retCode)){
				if("MD5".equalsIgnoreCase(signType)){
					String sign = "";
					SortedMap<String, String> nMap = new TreeMap<String, String>();
					nMap.put("platmerord", platmerord);
					nMap.put("qrcode", qrcode);
					nMap.put("retCode", retCode);
					nMap.put("retMsg", retMsg);
					sign = Signature.createSign(nMap, "9YQy38ePf6gQ");
					
					if(!sign.equals(signData)){
						retCode = "-40";
						retMsg = "验签失败!";
					}
				}
			}
			
			/*String inParameterStr = "";
			for (Map.Entry<String, String> entry : retmap.entrySet()) {
				inParameterStr = inParameterStr + entry.getKey() + " = " + entry.getValue() + "; ";
			}
			
			StringBuilder html = new StringBuilder();
			html.append("<script language=\"javascript\">window.onload=function(){alert(\"" + "交易返回码:" + retCode + "\\n交易返回信息:" + retMsg + "\\n返回参数信息:" + inParameterStr + "\")}</script>\n");
			response.setCharacterEncoding("utf-8");
			response.setContentType("text/html;charset=utf-8");
			response.getWriter().append(html).close();
			*/
			
			System.out.println("retCode >>>>> " + retCode);
			System.out.println("retMsg >>>>> " + retMsg);
			System.out.println("qrcode >>>>> " + qrcode);
			request.getSession().setAttribute("retCode", retCode);
			request.getSession().setAttribute("retMsg", retMsg);
			request.getSession().setAttribute("qrcode", qrcode);
			request.getRequestDispatcher("user/qrcode.jsp").forward(request, response);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}
	
//	private String paySubmit(Orders orders) throws Exception {
//		String agencyCode ="0";//分支机构号 
//		String cashier = "";
//		String remark1  ="商品";//备注 1
//		String remark2 ="";//备注 2
//		String remark3 ="";//备注 3
//		String signature ="";//签名
//		String shprivate = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJeqU5JaTEo4I214bVJZYkrRQZ1CWzSDXopqxc94ZELSO9RK2dHKLV59V1EWg41bkXhM+Y57YjtLp/wn4Tqe5iXq6yZtfHWKloSZ9yTNRYLbX45BRk30BIQ7xI/CnUVcHpckEl0SiAO2EeWeXFaVjE7CLD9MyuJAnVqmx2+YRjAzAgMBAAECgYBN8Sqhu+YY/mC2kX0dJPJuoLunpcJZamnbmKOvy5869+/nWdA3ED/gn2mQMpHIw5YuzOAzaRVCg88Atz34clCzwMPkLarBDWa+nhLv/aMnPU2SyM3ZQQ9M4en8BnmizoCUFvLqOGSezIDP6FHeaPljglNzv7qkPIFiGsNCEp/NAQJBANQLtzh12/euMun3nXbmUH8qDpHvAffDzYQSXFRmmnY8+CERsB9PUfgUAR/2ijTaMF3m2HAUI/4RUKCJguzTBEkCQQC3GoB28weS2SW/bnTY9nLvNIZyaC+JI8jzW2IglHvkhJDY3tuQeo4ZsU1g1OdLO3LyYuh602oMQ5ErDPAHvdibAkBOus7bcr8qVg5nWl2nwNnQbUAdpP05DgUnbV3EpJfjIL4MITIgXeYUUvEb+gDUoNJmewiPjJrUgX9LK+NlpO+pAkBNgK43qw7dnYRYzwwuecKUdYsjCe51Aeyg9WFHoRH/3AzjfxE4ymczgNTb08JDGdrBthPpSWtt3Xuo2UUQQc9ZAkAF25kJeb0cuUzJL97Tw/H6Pz1uWHdEwMht0yhtXHiAnvo3z55NSnXPctWcOkpjNKO/nexraYlxlg+koaJz+FfN";//密钥
//		//以下为业务1002必须参数
//		String cur = "CNY";//币种
////		bankType = "1041000";//银行行别
////		bankAccountType = "11";//付款方银行账户类型 
//		String timeout = "";//订单有效时间 
//		// 以下为业务2001必须参数
//		String platform = "";//终端类型
//		
//		Random ra =new Random();
//		Date date = new Date();
//		
//		String url = "http://zf.szjhzxxkj.com/ownPay/pay";//请求地址
////		String payCode ="6002";//业务号
//		String payMethod = "6002";//业务号
//		String merchantNo ="zz1491966120230VDD2O5L01X";//商户号
//		String requestNo = orders.getNo();
//		String amount = String.valueOf(orders.getMoney() * 100);
//		amount = amount.split("\\.")[0];
//		String backUrl = this.request.getScheme() + "://" + this.request.getServerName() + ":"
//				+ this.request.getServerPort() + this.request.getContextPath() + "/" + "notifyUrl";
//
//		String pageUrl = this.request.getScheme() + "://" + this.request.getServerName() + ":"
//				+ this.request.getServerPort() + this.request.getContextPath() + "/" + "returnUrl";
//		String payDate = String.valueOf(date.getTime());
//		String content = merchantNo + "|" + requestNo + "|" + amount + "|"+ pageUrl + "|" + backUrl + "|" + payDate +"|"+agencyCode+"|" + remark1 +"|" + remark2 +"|" + remark3 ;//拼接数据
//		
//		signature = RSASignature.sign(content, shprivate);
//		System.out.println(URLEncoder.encode(signature));
//		StringBuffer sbHtml = new StringBuffer();
//		sbHtml.append("<html>");
//		sbHtml.append("<head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>");
//		sbHtml.append("<body>");
//		sbHtml.append("<div style='font-size:16px;'></div>");
//		sbHtml.append("<form name='submit' action='" + url + "' method='post'>");
//		sbHtml.append("<input type='hidden'  name = 'merchantNo' id = 'merchantNo' value = \"" + merchantNo + "\" /></br>");
//		
//		sbHtml.append("<input type='hidden'  name = 'payMethod' id = 'payMethod' value = \"" + payMethod + "\" /></br>");
//		sbHtml.append("<input type='hidden'  name = 'cashier' id = 'cashier' value = \"" + cashier + "\" /></br>");
//		
//		sbHtml.append("<input type='hidden'  name = 'requestNo' id = 'requestNo' value = \"" + requestNo + "\" />");
//		sbHtml.append("<input type='hidden'  name = 'amount' id = 'amount' value = \"" + amount + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'pageUrl' id = 'pageUrl' value = \"" + pageUrl + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'backUrl' id = 'backUrl' value = \"" + backUrl + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'cur' id = 'cur' value = \"" + cur + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'timeout' id = 'timeout' value = \"" + timeout + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'payDate' id = 'payDate' value = \"" + payDate + "\"/>");
////		sbHtml.append("<input type='hidden'  name = 'payCode' id = 'payCode' value = \"" + payCode + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'remark1' id = 'remark1' value = \"" + remark1 + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'remark2' id = 'remark2' value = \"" + remark2 + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'remark3' id = 'remark3' value = \"" + remark3 + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'agencyCode' id = 'agencyCode' value = \"" + agencyCode + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'signature' id = 'signature' value = \"" + signature + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'bankType' id = 'bankType' value = \"" + bankType + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'bankAccountType' id = 'bankAccountType' value = \"" + bankAccountType + "\"/>");
//		sbHtml.append("<input type='hidden'  name = 'platform' id = 'platform' value = \"" + platform + "\"/>");
//		sbHtml.append("</form>");
//		sbHtml.append("<script>document.forms['submit'].submit();</script>");
//		sbHtml.append("</body>");
//		sbHtml.append("<html>");
//		
//		return sbHtml.toString();
//	}
	
	public Orders getOrders() {
		return this.orders;
	}

	public void setOrders(Orders orders) {
		this.orders = orders;
	}

	public String getFtlFileName() {
		return this.ftlFileName;
	}

	public void setFtlFileName(String ftlFileName) {
		this.ftlFileName = ftlFileName;
	}
	
}
